#!/bin/sh
cd `dirname $0`
bw_file=`pwd`/diskio-${RANDOM}.test
disk_test=200
disk_out_caption=`dd if=/dev/zero of=${bw_file} bs=${disk_test}M count=2 oflag=direct  2>&1  | tail -n 1  | grep -Po "\\d+(\\.\\d+)?\\D+$"`
disk_out=`echo ${disk_out_caption} | grep -Po "^\\d+"`


#echo disk_out_caption: $disk_out_caption
#echo disk_out: $disk_out


disk_in_caption=`dd if=${bw_file} of=/dev/null bs=${disk_test}M count=2  iflag=direct 2>&1  | tail -n 1  | grep -Po "\\d+(\\.\\d+)?\\D+$"`
disk_in=`echo ${disk_in_caption} | grep -Po "^\\d+"`


#echo disk_in_caption: $disk_in_caption
#echo disk_in: $disk_in
echo $disk_out,$disk_in
rm -f ${bw_file}
